package com.ailanyin.common.base.exception;


import lombok.Getter;
import lombok.Setter;

/**
 * 自定义 API异常
 *
 * @author ailanyin
 * @version 1.0
 * @since 2021-08-31
 */
@Getter
@Setter
public class ApiException extends RuntimeException {

    /**
     * 错误码
     */
    private Integer errorCode;

    /**
     * 错误信息
     */
    private String message;

    public ApiException(String message) {
        this.message = message;
    }

    public ApiException(Integer code, String message) {
        this.message = message;
        this.errorCode = code;
    }

    /**
     * 不打印堆栈信息, 提高性能
     *
     * @return this
     */
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
